/**
 * 
 */
package edu.cmu.cs.webapp.ioms.test;

import java.util.GregorianCalendar;
import java.util.Random;

import edu.cmu.cs.webapp.ioms.models.Client;
import edu.cmu.cs.webapp.ioms.models.Ingredient;
import edu.cmu.cs.webapp.ioms.models.LineItem;
import edu.cmu.cs.webapp.ioms.models.OrderStatus;
import edu.cmu.cs.webapp.ioms.models.Product;
import edu.cmu.cs.webapp.ioms.models.PurchaseOrder;
import edu.cmu.cs.webapp.ioms.models.impl.IOMSFactoryImpl;

/**
 * @author Christian
 * 
 */
public class DummieDataGenerator {

	/**
	 * Generate dummy orders data
	 * 
	 * @return
	 */
	public PurchaseOrder[] getOrders() {
		PurchaseOrder[] orders = new PurchaseOrder[30];
		for (int i = 0; i < 30; i++) {
			PurchaseOrder o = IOMSFactoryImpl.eINSTANCE.createPurchaseOrder();
			o.setOrder_id(1000 + i);
			o.setExpected_shipping_date(new GregorianCalendar(2001, 02, 03)
					.getTime());
			o.setOrder_date(new GregorianCalendar(2001, 02, 03).getTime());
			o.setStatus(OrderStatus.get(new Random().nextInt(3)));
			// o.setStatus("Pending");
			o.setShipping_address(i + " Shipping Address Avenue");
			o.setShipping_city("Pittsburgh");
			o.setShipping_country("US");
			o.setShipping_state("PA");

			Client c = IOMSFactoryImpl.eINSTANCE.createClient();
			c.setFname("Client");
			c.setLname("" + i);
			o.setClient(c);

			LineItem item = IOMSFactoryImpl.eINSTANCE.createLineItem();
			item.setItem_id(1000 + i);
			item.setQuantity(7);
			o.getItems().add(item);

			LineItem item2 = IOMSFactoryImpl.eINSTANCE.createLineItem();
			item2.setItem_id(1000 + i);
			item2.setQuantity(10);
			o.getItems().add(item2);
			orders[i] = o;
		}

		return orders;
	}

	/**
	 * 
	 * @return
	 */
	public Product[] getProducts() {
		Product[] products = new Product[30];
		for (int i = 0; i < 30; i++) {
			Product p = IOMSFactoryImpl.eINSTANCE.createProduct();
			p.setProd_id(1000 + i);
			p.setProd_name("Product " + i);
			p.setProd_description("Testing Product " + i);
			p.setPrice(i * 10);
			products[i] = p;
		}

		return products;
	}

	/**
	 * 
	 * @return
	 */
	public Client[] getCustomers() {
		Client[] clients = new Client[30];
		for (int i = 0; i < 30; i++) {
			Client c = IOMSFactoryImpl.eINSTANCE.createClient();
			c.setClient_id(1000 + i);
			c.setFname("Client");
			c.setLname("" + i);
			c.setAddress("11" + i + " Verjia Avenue");
			c.setCity("Pittsburgh");
			c.setCompany("CMU");
			c.setPhone("911");
			c.setState("PA");
			c.setCountry("USA");
			clients[i] = c;
		}

		return clients;
	}

	public Ingredient[] getInventory() {
		Ingredient[] vs = new Ingredient[30];
		for (int i = 0; i < 30; i++) {
			Ingredient inv = IOMSFactoryImpl.eINSTANCE.createIngredient();
			inv.setIng_id(1000 + i);
			inv.setName("Client");
			inv.setUnit_cost(i * new Random().nextDouble());
			inv.setInventory(i * new Random().nextDouble());
			vs[i] = inv;
		}

		return vs;
	}

}
